import random


def start():
    name = input('请输入你的名字：')
    if name == '退出':
        return
    if name not in history:
        history[name] = []
    answer = random.randint(0, 1024)
    try_to_guess(name, answer)


def try_to_guess(name, answer):
    try_nume = 0
    while try_nume < 100:
        guess_answer = int(input('请输入一个你猜测的数字：'))
        if guess_answer < answer:
            print('你输入的数字小于正确答案')
        elif guess_answer > answer:
            print('你输入的数字大于正确答案')
        else:
            print('恭喜你回答正确！')
            history[name].append('成功！')
            break
        try_nume += 1
    else:
        print('猜测错误次数过多，游戏失败！')
        history[name].append('失败！')


history = {}


def show_history():
    for name, data in history.items():
        print('用户：{}, 记录如下：{}'.format(name, data))


def default():
    print('输入错误！请重新输入')
    print('=' * 40)


if __name__ == '__main__':
    select_dict = {'1': start, '2': show_history, '3': exit}
while True:
    select = input('1.开始游戏\n2.历史记录\n3.退出游戏\n请输入数字选择：')
    select_dict.get(select, default)()
